<?php
/**
 * ShopEx licence
 *
 * @copyright  Copyright (c) 2005-2010 ShopEx Technologies Inc. (http://www.shopex.cn)
 * @license  http://ecos.shopex.cn/ ShopEx License
 */
 

/*
 * @package base
 * @copyright Copyright (c) 2010, shopex. inc
 * @author edwin.lzh@gmail.com
 * @license 
 */
abstract class base_kvstore_abstract 
{
    
    /*
     * 生成经过处理的唯一key
     * @var string $key
     * @access public
     * @return string
     */
    public function create_key($key) 
    {
        return md5(base_kvstore::kvprefix() . $this->prefix . $key);
    }//End Function

    /*
     * 自增
     * @var string $key
     * @var int $offset
     * @access public
     * @return mixed
     */
    public function increment($key, $offset=1) 
    {
       /*
       if(is_numeric($offset) && $offset>0){
           if($this->fetch($key, $value)){
               if(!is_int($value) || $value<0)  return 0;   //如果不是正整数
               $value += intval($offset);
               if($this->store($key, $value)){
                   return $value;
               }
           }else{
               trigger_error('offset has to be > 0', E_USER_WARNING);
           }
       }
       */
       return false;
    }//End Function

    /*
     * 自减
     * @var string $key
     * @var int $offset
     * @access public
     * @return mixed
     */
    public function decrement($key, $offset=1) 
    {
       /*
       if(is_numeric($offset) && $offset>0){
           if($this->fetch($key, $value)){
               if(!is_int($value) || $value<0)  return 0;   //如果不是正整数
               $value -= intval($offset);
               if($value < 0)   $value = 0;
               if($this->store($key, $value)){
                   return $value;
               }
           }else{
               trigger_error('offset has to be > 0', E_USER_WARNING);
           }
       }
       */
       return false;
    }//End Function

}//End Class